/**
 * 解除元素绑定事件
 * @date 2020-08-18
 * @param {String} eventName
 */
HTMLElement.prototype.unbind = function (eventName) {
  if ("on" + eventName in this) {
    this["on" + eventName] = null;
  }
  if (getEventListeners(this).hasOwnProperty(eventName)) {
    getEventListeners(this)[eventName].forEach((i) => this.removeEventListener(eventName, i.listener));
  }
  console.log("清除完毕");
};

/**
 * 对所有 DOM 清除一类事件
 * @date 2020-08-18
 * @param {String} eventName
 */
function removeEvent(eventName) {
  let all = [document, ...document.querySelectorAll("*")];
  let list = all.filter((i) => getEventListeners(i).hasOwnProperty(eventName));
  list.forEach((i) => {
    getEventListeners(i)[eventName].forEach((ii) => i.removeEventListener(eventName, ii.listener));
  });
}
